//
//  MZFontDemoViewController.m
//  MZBaseDemo
//
//  Created by Chris Yang on 2016/12/2.
//  Copyright © 2016年 Chris Yang. All rights reserved.
//

#import "UIFont+MZCategory.h"
#import "FontInfoView.h"

#import "MZFontDemoViewController.h"

@interface MZFontDemoViewController ()

@property (nonatomic, strong) UIScrollView *scrollView;

@end

@implementation MZFontDemoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self selfConfig];
    [self setupSubviews];
}

- (void)selfConfig {
    [UIFont mzSetDefaultFontName:@"DFPHaiBaoW12-GB"];   /* 资源文件添加的字体 */
    [self.view setBackgroundColor:[UIColor whiteColor]];
}

- (void)setupSubviews {
    
    /* Scroll View */
    _scrollView = [[UIScrollView alloc] init];
    [_scrollView setUserInteractionEnabled:YES];
    [self.view addSubview:_scrollView];
    [_scrollView setFrame:self.view.bounds];
    
    __block CGRect tmpRect = self.view.bounds;
    tmpRect.origin.y = 40;
    tmpRect.size.height = 30;
    
    for (NSInteger i=0; i<12; i++) {
        FontInfoView *fontView = [[FontInfoView alloc] init];
        
        [fontView setFrame:tmpRect];
        tmpRect.origin.y += 30;
        
        switch (i) {
            case 0:
                [fontView.testLabel setFont:MZFontMoney48];
                fontView.testLabel.text=@"1234567890";
                break;
            case 1:
                [fontView.testLabel setFont:MZFontBold28];
                break;
            case 2:
                [fontView.testLabel setFont:MZFontBold24];
                break;
            case 3:
                [fontView.testLabel setFont:MZFontMedium24];
                break;
            case 4:
                [fontView.testLabel setFont:MZFontBold20];
                break;
            case 5:
                [fontView.testLabel setFont:MZFontRegular18];
                break;
            case 6:
                [fontView.testLabel setFont:MZFontMedium18];
                break;
            case 7:
                [fontView.testLabel setFont:MZFontMedium16];
                break;
            case 8:
                [fontView.testLabel setFont:MZFontRegular16];
                break;
            case 9:
                [fontView.testLabel setFont:MZFontRegular14];
                break;
            case 10:
                [fontView.testLabel setFont:MZFontBold14];
                break;
            case 11:
                [fontView.testLabel setFont:MZFontRegular12];
                break;
                
            default:
                break;
        }
        [fontView.fontNameLabel setFont:mzAdaptiveFont(14, 3)];
        [fontView.fontNameLabel setText:[NSString stringWithFormat:@"%@%ld", @"规定字体",i+1]];
        [_scrollView addSubview:fontView];
    }
    
    [UIFont mzTraversalFontWithFontFamilyCallback:^(NSString *fontFamily) {
        NSLog(@"%@",fontFamily);
    } fontNameCallback:^(NSString *fontName) {
        NSLog(@"%@",fontName);
        FontInfoView *tmpView = [FontInfoView fontViewWithFontName:fontName];
        
        [_scrollView addSubview:tmpView];
        
        [tmpView setFrame:tmpRect];
        tmpRect.origin.y += 30;
    }];
    
    /* Scroll View Content Size */
    tmpRect.size.height = tmpRect.origin.y + 50;
    [_scrollView setContentSize:tmpRect.size];
}

@end
